using System;
using System.IO;

namespace WordsHelper.DAL.Services
{
    public static class DALService
    {
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException"></exception>
        public static void MoveDataFrom(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (path.Length == 0)
            {
                throw new ArgumentException("Empty String.", "path");
            }
            File.Delete(DataSourceRepository.DataDataSource.FileName);
            File.Move(path, DataSourceRepository.DataDataSource.FileName);
        }
        /// <exception cref="IOException"></exception>
        public static void MoveDataFromBak()
        {
            MoveDataFrom(DataSourceRepository.DataDataSource.FileName + ".bak");
        }
        /// <exception cref="IOException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException"></exception>
        public static void CopyDataTo(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (path.Length == 0)
            {
                throw new ArgumentException("Empty String.", "path");
            }
            File.Delete(path);
            File.Copy(DataSourceRepository.DataDataSource.FileName, path);
        }
        /// <exception cref="IOException"></exception>
        public static void CopyDataToBak()
        {
            CopyDataTo(DataSourceRepository.DataDataSource.FileName + ".bak");
        }
    }
}